﻿using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using Queer.AutoJob.Core.Business;
using Queer.AutoJob.Core.Entity;
using Queer.AutoJob.Core.Model;
using Queer.Util.Model;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Queer.WebApi.Areas.Admin.SystemManage
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-04-01 09:29
    /// 描 述：定时任务日志控制器类
    /// </summary>
    [ApiDescriptionSettings("Admin", SplitCamelCase = false)]
    [Route("AutoJobManage/[controller]")]
    public class AutoJobLogController : IDynamicApiController
    {
        private readonly IAutoJobLogBLL _autoJobLogBLL;

        public AutoJobLogController(IAutoJobLogBLL autoJobLogBLL)
        {
            _autoJobLogBLL = autoJobLogBLL;
        }

        #region 获取数据

        /// <summary>
        /// 条件查询
        /// </summary>
        [HttpGet]
        public async Task<TData<List<AutoJobLogEntity>>> GetListJson([FromQuery] AutoJobLogListParam param)
        {
            TData<List<AutoJobLogEntity>> obj = await _autoJobLogBLL.GetList(param);
            return obj;
        }

        /// <summary>
        /// 条件查询-分页
        /// </summary>
        [HttpGet]
        public async Task<TData<List<AutoJobLogEntity>>> GetPageListJson([FromQuery] AutoJobLogListParam param, [FromQuery] Pagination pagination)
        {
            TData<List<AutoJobLogEntity>> obj = await _autoJobLogBLL.GetPageList(param, pagination);
            return obj;
        }

        /// <summary>
        /// 根据ID查询
        /// </summary>
        [HttpGet]
        public async Task<TData<AutoJobLogEntity>> GetFormJson([FromQuery] long id)
        {
            TData<AutoJobLogEntity> obj = await _autoJobLogBLL.GetEntity(id);
            return obj;
        }

        #endregion

        #region 提交数据

        /// <summary>
        /// 新增/修改 数据
        /// </summary>
        [HttpPost]
        public async Task<TData<string>> SaveFormJson([FromBody] AutoJobLogEntity entity)
        {
            TData<string> obj = await _autoJobLogBLL.SaveForm(entity);
            return obj;
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        [HttpPost]
        public async Task<TData> DeleteFormJson([FromBody] ParamModel model)
        {
            TData obj = await _autoJobLogBLL.DeleteForm(model.ids);
            return obj;
        }

        #endregion
    }
}